home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / comm / tlx_sq15.zip / PSHDIR1A.ZIP / POPDIR.ASM next >
Assembly Source File  |  1988-12-22  |  3KB  |  101 lines

  1. main    group    code
  2. code    segment    public    para    'code'
  3. assume    cs:main
  4.  
  5. org    100h                ;.COM file
  6.  
  7. BEGIN:    jmp    START            ;program starts here
  8. ;        db    "Copyright 1986 Ziff-Davis Publishing Co.",1Ah
  9. ;            Changes made on 12/22/88 by Mike Williams
  10. ;            1. Support command line parm to also CHDIR
  11. ;            2. If path string refers to a drive, log that drive
  12. ;
  13. signature    db    'PUSHDIR VERSION 1.a'
  14. lengthsignature = $ - signature
  15.  
  16. savedint16    dd    ?        ;used to be identical to pushdir
  17.  
  18. nextpush    dw    offset main:push1dir    ;next place to save a dir
  19. push1dir    db    67 dup (0)
  20. push2dir    db    67 dup (0)
  21. push3dir    db    67 dup (0)
  22. push4dir    db    67 dup (0)
  23. push5dir    db    67 dup (0)
  24. push6dir    db    67 dup (0)
  25.  
  26. ;up to here must be EXACTLY identical in both PUSHDIR and POPDIR.
  27.  
  28. notinstalled1    db    'Must run PUSHDIR.COM before POPDIR.COM'
  29.         db    ' will do anything.',13,10,10,'$'
  30. errpop1        db    'Error popping the current directory',13,10,10,'$'
  31.  
  32. START:
  33.     sti                ;interrupts on
  34.  
  35.     ;is PUSHDIR already installed ?
  36.  
  37.     mov    ax,7788h            ;signature request
  38.     mov    bx,7789h            ;signature request
  39.     mov    si,offset main:signature    ;point ds:si to signature
  40.     int    16h            ;is it installed ?
  41.     
  42. assume    ds:nothing
  43.     
  44.     cmp    bx,7788h            ;were ax and bx switched ?
  45.     jne    NOTINSTALLED        ;no
  46.     cmp    ax,7789h            ;were ax and bx switched ?
  47.     jne    NOTINSTALLED        ;no
  48.     jmp    short ISINSTALLED        ;yes - continue, no error
  49. NOTINSTALLED:
  50.  
  51.     ;here PUSHDIR was not previously installed so POPDIR can't do anything
  52.     ;useful so we just terminate with an error message.
  53.  
  54.     mov    dx,offset main:notinstalled1    ;error message
  55.     mov    ah,9
  56.     int    21h
  57.     int    20h            ;exit
  58.  
  59.  
  60. ISINSTALLED:
  61.  
  62.     ;get the address of the directory previously saved by pushdir
  63.  
  64.     mov    bp,ds:[nextpush]        ;get the next push location
  65.     sub    bp,67                ;back up one to the last push
  66.     cmp    ds:[nextpush],offset main:push1dir    ;need to wrap back ?
  67.     jne    NOWRAPBACK            ;no
  68.     mov    bp,offset main:push6dir        ;yes, wrap back
  69. NOWRAPBACK:
  70.  
  71.     ;set the current directory
  72.  
  73.     mov    dx,bp            ;load ds:dx with directory to set
  74.     mov    ah,3bh            ;dos function number
  75.     int    21h            ;set current dir back
  76.     jc    ERRPOP            ;branch on error
  77.     mov    ds:[nextpush],bp    ;update [nextpush] if successful
  78.  
  79.     ;set the current drive also    
  80.  
  81.     mov    dl,ds:[bp]            ;get drive letter from path
  82.     sub    dl,'A'                ;convert to binary (0=A, 1=B)
  83.     mov    ah,0eh                ;dos function number
  84.     int    21h                ;set drive
  85.  
  86.     ;exit successfully with no message
  87.  
  88.     int    20h                 ;exit
  89.  
  90. ERRPOP:
  91.     push    cs
  92.     pop    ds                ;set ds = cs
  93.     mov    dx,offset main:errpop1        ;error message
  94.     mov    ah,9                ;dos function number
  95.     int    21h                ;show the message
  96.     int    20h                ;terminate
  97.     
  98. code    ends
  99. end    BEGIN                ;start execution at BEGIN
  100. 
  101.